#include<stdio.h>
#include<string.h>
char a[1000];
int main(){
    int k1,k2,k3;
    k1=0;
    k2=0;
    k3=0;
    fgets(a,sizeof(a),stdin);
    int leng=strlen(a);
    int i=0;
    char stack[1004];
    int head=-1;
       while(a[i]!='\0'){
        if(a[i]=='('||a[i]=='{'||a[i]=='['){
            head++;
            stack[head]=a[i];
        }
           if(a[i]==')'||a[i]=='}'||a[i]==']'){
            if(a[i]==')'&&stack[head]!='(')break;
            if(a[i]=='}'&&stack[head]!='{')break;
            if(a[i]==']'&&stack[head]!='[')break;
            head--;
        }
        i++;
        }
    if(head==-1)printf("YES");
    else printf("NO");
    return 0;
}